package com.active.fnd.arch.application.model
{
	import mx.core.ClassFactory;
	import mx.core.UIComponent;

	class Node
	{
		public var name:String;
		public var pmClass:Class;
		public var viewClass:Class;
		public var tabIndex:int;

		public function Node(name:String, pmClass:Class, viewClass:Class, tabIndex:int = 0)
		{
			this.name=name;
			if (pmClass)
			{
				this.pmClass=pmClass;
			}
			else
			{
				this.pmClass=NULLNodePM;
			}
			this.viewClass=viewClass;
			this.tabIndex = tabIndex;
		}

		public function createPM():NodePM
		{
			var myClassFactory:ClassFactory=new ClassFactory(pmClass);
			var pm:NodePM=myClassFactory.newInstance();
			pm.addToPMContext();
			return pm;
		}

		public function createView():UIComponent
		{
			var myClassFactory:ClassFactory=new ClassFactory(viewClass);
			var view:UIComponent=myClassFactory.newInstance();
			return view;
		}
	}
}